package mapper;

import com.yh.javabean.User;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @Auther: Liang
 * @Date: 2024/5/9 - 05 - 09 - 18:22
 * @Description: mapper
 * @version: 1.0
 */
public interface UserMapper {


    @Select("select * from user")
    //使用注解完成一对一映射查询
    @Results(id = "u_r",value = {
            @Result(id = true,column = "uid",property = "uid"),
            @Result(column = "username",property = "username"),
            @Result(column = "password",property = "password"),
            @Result(column = "phone",property = "phone"),
            @Result(property = "r",column = "uid",one = @One(select ="mapper.RoleMapper.selectByUid",fetchType = FetchType.LAZY))
    })


    List<User> selectAllUserAndRole();
}
